<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .herad {
            position: relative;
            width: 100%;
            height: 100vh;
            background: url(./poster.47f71d4.jpg) no-repeat center/cover;
        }

        .herad_dr {
            width: 400px;
            height: 200px;
            border: 3px solid black;
            border-radius: 15px;
            font-size: 20px;
            color: aliceblue;
            background: rgba(167, 232, 255, 0.7);
            margin: 0 auto;
            /* text-align: center;
            line-height: 60px; */
            display: flex;
            flex-wrap: wrap;
            justify-items: center;
            align-items: center;
            justify-content: center;
            position: absolute;
            top: 30%;
            left: 40%;
        }

        .herad_dr div {
            width: 400px;
            height: 50px;

        }

        #yzm {
            display: inline-block;
            width: 80px;
            height: 50px;
            background-color: orange;
            border-radius: 15px;
            line-height: 50px;
            text-align: center;
            margin-left: 25px;
        }

        #dr {
            width: 150px;
            height: 30px;
            background-color: skyblue;
            border-radius: 15px;
        }
    </style>
</head>

<body>
    <div class="herad">
        <div class="herad_dr">
            <div>手机号：<input type="text" id="phone"></div>
            <div> 验证码：<input type="text" id="phone_code"><input type="submit" id="yzm" onclick="arr()"
                    value="验证码"></input></div>
            <button id="dr" onclick="dr_1()">登入</button>
        </div>
    </div>
    <script src="./jquery-3.7.1(2).js"></script>
    <script>

        let a = 60
        let b = document.getElementById("yzm");
        function arr() {
            // 验证码
            $.ajax({
                url: "http://43.143.211.183:8889/sendSms/" + $("#phone").val(),
                type: "get",
                data: {

                },
                success: function (res) {
                    console.log(res)
                    let arr1 = setInterval(function () {
                        if (a == 0) {
                            clearInterval(arr1)
                            a = 60
                            b.setAttribute("value", "验证码")
                        } else {
                            b.setAttribute("value", a + "秒")
                            a--
                        }
                    }, 1000)
                }
            })
        }
        // 登入
        function dr_1() {
            $.ajax({
                url: "http://172.16.106.87:8080/upDataGoods",
                type: "post",
                data: JSON.stringify({
                    phone: $("#phone").val(),
                    phone_code: $("#phone_code").val(),
                    invite_code: "",
                }),
                contentType: 'application/json',
                success: function (res) {
                    console.log(res)
                }
            })
        }
    </script>
</body>

</html>